package com.mybatis.panel;

import com.mybatis.entity.User;
import com.mybatis.service.UserService;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class SelectPanel extends JPanel {

    public static int pageSize = 1;

    public static String dataRow;

    public SelectPanel() {
        setLayout(null);
        setBounds(0, 0, 400, 300);

        //===========================================
//        JPanel panel = new JPanel(new BorderLayout());
//        panel.setBounds(0, 0, 900, 600);//位置
//        panel.add(new JLabel("用户名"));//文字


        JPanel panel2 = new JPanel();
        panel2.setBounds(0, 140, 0, 0);
        add(panel2);



        JButton button1 = new JButton("查看学生基本信息");
        JButton button2 = new JButton("查看学生奖惩记录");
        JButton button3 = new JButton("查看学生学籍信息");
        JButton button4 = new JButton("返回登陆");
        String user;
        if (MainJFrame.userType==1)
            user="管理员";
        else user="普通用户";
        JButton button5 = new JButton("当前身份: "+user);
        button5.setBounds(0,0,150,20);
        button5.setMargin(new Insets(0, 0, 0, 0));
        add(button5);

        button1.setBounds(100,50,200,40);
        button1.setMargin(new Insets(0, 0, 0, 0));
        add(button1);

        button2.setBounds(100,100,200,40);
        button2.setMargin(new Insets(0, 0, 0, 0));
        add(button2);

        button3.setBounds(100,150,200,40);
        button3.setMargin(new Insets(0, 0, 0, 0));
        add(button3);

        button4.setBounds(150,200,100,30);
        button4.setMargin(new Insets(0, 0, 0, 0));
        add(button4);


        button1.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                MainJFrame.jFrame.setSize(900,600);
                setPanel(new StudentPanel());
            }
        });

        button2.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                MainJFrame.jFrame.setSize(900,600);
                setPanel(new AwardPunishPanel());
            }
        });

        button3.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                MainJFrame.jFrame.setSize(900,600);
                setPanel(new SstatusPanel());
            }
        });

        button4.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                MainJFrame.jFrame.setSize(300,300);
                setPanel(new LoginPanel());
            }
        });





    }

    public void setPanel(int page) {
        pageSize = page;
        MainJFrame.setPanel(new SelectPanel());
    }

    public void setPanel(JPanel panel) {
        MainJFrame.setPanel(panel);
    }

}
